from mqttdemo.mqtt1.mqttutil import MqttUtil

# 创建 MqttUtil 实例并接收消息
mqtt_client = MqttUtil("localhost", client_id="SubscriberClient")
mqtt_client.connect()
mqtt_client.subscribe("test/topic")
mqtt_client.loop_start()  # 开始监听消息

# 保持运行以持续接收消息
try:
    while True:
        pass
except KeyboardInterrupt:
    mqtt_client.loop_stop()
    mqtt_client.disconnect()
